# global & local
def f():
    a = 1
    print("here is function f scope")
    print(f"{'a' in globals() = }")
    print(f"{'a' in locals() = }")
f()
print("here is global scope")
print(f"{'a' in globals() = }")
print(f"{'a' in locals() = }")

# change scope
def g():
    global b
    b = 2
    print("here is function g scope")
    print(f"{'b' in globals() = }")
g()

# closure
def counter():
    count = 0
    def add():
        nonlocal count
        count += 1
        return count
    return add
c = counter()
for i in range(3):
    print(c(), end="\t")
